home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17682 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.primenet.com!ip068
  2. From: rogersr@primenet.com (Randy Rogers)
  3. Newsgroups: comp.lang.c++,comp.lang.c,comp.os.ms-windows.programmer.misc
  4. Subject: Re: fastest code
  5. Date: 16 Apr 1996 23:47:01 -0700
  6. Organization: Primenet
  7. Sender: root@primenet.com
  8. Message-ID: <4l2455$22f@nnrp1.news.primenet.com>
  9. References: <316112A2.7D37@public.sta.net.cn> <4kjpn0INN817@keats.ugrad.cs.ubc.ca> <829352535snz@genesis.demon.co.uk> <4kof6e$te@news1.mnsinc.com> <4krbhlINNbk4@keats.ugrad.cs.ubc.ca> <3171E8D2.41C67EA6@scn.de>
  10. X-Posted-By: ip068.phx.primenet.com
  11. X-Newsreader: News Xpress Version 1.0 Beta #4
  12.  
  13. In article <3171E8D2.41C67EA6@scn.de>,
  14.    Gerolf Wendland <wendland%hpp015%hpp001.mch2.scn.de@scn.de> wrote:
  15. >Kazimir Kylheku wrote:
  16. >It was addition instead of multiplication by constant values (i+i instead of 
  17. 2*i)
  18. >
  19. >> If I were writing a compiler, I wouldn't bother ``optimizing'' this case at
  20. >> all: If the programmer thinks he knows better, let him have his addition!
  21. >
  22. >Let the programmer write down his way of solving the problem.
  23. >Let the compiler try to do the tideous optimization as much as possible.
  24.  
  25.  
  26. Why not just look at the machine code with the debugger?
  27. there is also an issue of whether signed arithemetic is being performed
  28. if not  you could just shift left 1, add, or multiply with the same result
  29. how large are the vars...doubles would require additional register usage
  30.  
  31. its my guess that any decent compiler is smart eough to optimize the 
  32. multiplications to shifts and/or adds if possible to increase speed.
  33. if optimizations were selected to minimize memory usage the result may be 
  34. different.
  35.  
  36. randy
  37.